
<template>
    <div class="resource-manage">
        <div class="card-box">
            <div class="card-title">
                <span>物业权属</span>
                <el-button-group v-show="false">
                    <el-button :disabled="true" v-for="item in propertyOwnerships" :key="item.value" size="small" :type="propertyOwnership == item.value?'primary':'default'" >{{item.label}}</el-button>
                </el-button-group>
            </div>
            <div class="card-box">
                <!--<div class="card-title">
                    <span>{{dictCh(propertyOwnership,'property_ownerships')}}</span>
                </div>-->
                <div>
                    <div class="main-propertyForms" v-if="propertyOwnership == '10'">
                        <el-table :data="propertyForms" align="center">
                            <el-table-column label="建设单位" prop="constructionUnit"></el-table-column>
                            <el-table-column label="建设开始日期" :formatter="dataFormat" prop="constructionStartTime"></el-table-column>
                            <el-table-column label="竣工日期" :formatter="dataFormat" prop="completedTime"></el-table-column>
                            <el-table-column label="资产占用单位" prop="assetOccupyingUnit"></el-table-column>
                            <el-table-column label="上级主管单位" prop="superiorCompetentUnit"></el-table-column>
                            <el-table-column label="资产使用单位" prop="assetUseUnit"></el-table-column>
                        </el-table>
                    </div>
<!--                    <el-form v-if="propertyOwnership == '10'" class="form-wrap" size="small" >-->

<!--                        <el-form-item  label="建设单位">-->
<!--                            <el-col class="in_txt">{{propertyForm.constructionUnit}}</el-col>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="建设开始日期" >-->
<!--                            <el-col class="in_txt">{{propertyForm.constructionStartTime}}</el-col>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="竣工日期">-->
<!--                            <el-col class="in_txt">{{propertyForm.completedTime}}</el-col>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="资产占用单位" >-->
<!--                            <el-col class="in_txt">{{propertyForm.assetOccupyingUnit}}</el-col>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="上级主管单位">-->
<!--                            <el-col class="in_txt">{{propertyForm.superiorCompetentUnit}}</el-col>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="资产使用单位">-->
<!--                            <el-col class="in_txt">{{propertyForm.assetUseUnit}}</el-col>-->
<!--                        </el-form-item>-->
<!--                    </el-form>-->
                    <el-form v-else ref="borrowForm" :model="borrowForm" class="form-wrap" size="small" >
                        <el-form-item label="物业归属方" v-if="propertyOwnership == '20' || propertyOwnership == '30' || propertyOwnership == '40' || propertyOwnership == '60'">
                            <el-col class="in_txt">{{borrowForm.propertyBelong}}</el-col>
                        </el-form-item>
                        <el-form-item label="当前管理人" v-if="propertyOwnership == '20' || propertyOwnership == '30' || propertyOwnership == '40' || propertyOwnership == '60'">
                            <el-col class="in_txt">{{borrowForm.currentManager}}</el-col>
                        </el-form-item>
                        <el-form-item label="无产权原因" v-if="propertyOwnership == '40' ">
                            <el-col class="in_txt">{{borrowForm.propertyReason}}</el-col>
                        </el-form-item>
                        <el-form-item label="其他权属证明" v-if="propertyOwnership == '50' ">
                            <el-col class="in_txt">{{borrowForm.propertyCertificate}}</el-col>
                        </el-form-item>
                        <el-form-item label="其他权属年限" v-if="propertyOwnership == '50' " >
                            <el-col class="in_txt">{{borrowForm.propertyYear}}</el-col>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import { getDict } from '~/utils'
    import { doubleValidate} from '~/utils/validate.js'
    let moment = require('moment')

    export default {
        name: "property-ownership",
        data() {
            return {
                labelName: '',
                propertyOwnership: '',
                input: '',
                value: '',
                propertyForms: [],
                propertyForm: {
                    constructionUnit: '',
                    constructionStartTime: '',
                    completedTime: '',
                    assetOccupyingUnit: '',
                    superiorCompetentUnit: '',
                    assetUseUnit: ''
                },
                borrowForm:{
                    propertyBelong: '',
                    propertyInfoId: '',
                    currentManager: '',
                    propertyReason: '',
                    propertyCertificate: '',
                    propertyYear: ''
                },
                propertyOwnerships: [],
            }
        },
        created() {
            this.propertyOwnerships = getDict('property_ownerships')
        },
        methods: {
            dataFormat:function(row,column,cellValue) {
                if (!cellValue) {
                    return ''
                }
                return moment(cellValue).format('YYYY-MM-DD')
            },

            dictCh(val, dictName){
                if(val && dictName){
                    let dict = getDict(dictName)
                    if(dict){
                        let find = dict.find(d => d.value == val)
                        if(find){
                            return find.label
                        }
                    }
                }
                return ""
            },
            initOwner(propertyInfo, propertyCard, propertyOwnership){
                if(propertyInfo){
                    this.borrowForm = propertyInfo
                }
                if(propertyCard){
                    let pform = {
                        constructionUnit: propertyCard.constructionUnit,
                        constructionStartTime: propertyCard.constructionStartTime,
                        completedTime: propertyCard.completedTime,
                        assetOccupyingUnit: propertyCard.assetOccupyingUnit,
                        superiorCompetentUnit: propertyCard.superiorCompetentUnit,
                        assetUseUnit: propertyCard.assetUseUnit
                    }
                    this.propertyForm = pform
                    this.propertyForms.push(this.propertyForm)
                }
                this.propertyOwnership = propertyOwnership
            }
        }
    }
</script>

<style scoped lang='scss'>


    @include formWrap();
    .in_txt {
        color: #999999;
    }
    .main-propertyForms {
        padding: 16px 24px;
        box-sizing: border-box;
    }
</style>
